package com.ytc.util;

import java.util.ArrayList;
import java.util.List;

/**
 * 对查询结果进行分页
 */
public class RankingPageUtilHelper {
    public static <T> RankingPageUtil pageHelper(List<T> list, Integer cpage, Integer pageSize) {

        Long totalRow = Long.valueOf(list.size());
        RankingPageUtil<T> pageInfo = new RankingPageUtil(cpage, totalRow, pageSize);
        List<T> pageList = new ArrayList<>();
        for (int i = 0; i < pageSize; i++) {
            if ((cpage-1)*pageSize+i < list.size())
                pageList.add(list.get((cpage-1)*pageSize+i));
        }
        pageInfo.setList(pageList);
        return pageInfo;
    }
}
